<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    	<meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>iRestauranting - Restaurante <?php
            echo $_GET['search_resto'];
                ?></title>
		<link rel="icon" href="img/favicon.ico" type="image/x-icon" >
    	<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <!-- Magnific Popup core CSS file -->
    	<link rel="stylesheet" href="css/magnific-popup.css">
        <link rel="stylesheet" media="all" href="css/irestauranting_fb.css" />
        <link rel="stylesheet" media="all" href="css/tabs_fb.css" />
		<link href='https://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
        <meta name="description" content="Informe detallado de la reputación online del restaurante <?php echo $_GET['search_resto'];?>" >
</head>

<body>
	
	<div id="container">
        <div id="resto_header">
        	<div id="header-center">
                <div style="float:left">
                	<a href="index.html"><img src="img/LogoHome.png" /></a>
                </div>             
             </div>
         </div>
         <div id="separador_header">
         </div>	
         <div style="clear:both" ></div>
         
        <div id="container_titulo_resto">
            	<div id="titulo_resto" class="titulo_resto" >
                	
                </div>
                
				
                <div id="adress_resto" class="adress_resto">
                	
                </div>              	
				
         </div>
         <br>
    <div id="container_plantilla_opiniones">
       
       <div style="height:700px;">
        	<div style="position:absolute;top:50%;left:50%;margin:-40px 0 0 -40px;" />
        		<img src="img/spinner.gif" />
            </div>
       </div>
    </div>
	 <div style="clear:both" ></div>
	 <div id="separador_footer">
     </div>
	 <div id="resto_footer">
		<div id="header-center">
			<div style="float:left">
				
			</div>			
		 </div>
	 </div>
	<!--
     <footer id="resto_footer"><br></footer>
	-->
	 
    <script src="js/jquery-1.9.1.js"></script>  
    <script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
	<script src="js/tabs.js"></script>
    
    <script type="text/javascript">
    
    var intervalo_fechas = '<?php echo $_GET['intervalo']; ?>';
    var id_resto = '<?php echo $_GET['id_resto']; ?>';
    var mail = '<?php echo isset($_GET['mail']) ? $_GET['mail'] : 0 ?>';
	var campaign = 	'<?php echo isset($_GET['camp']) ? $_GET['camp'] : 0 ?>';
	var opiniones =  '<?php echo isset($_GET['opiniones']) ? $_GET['opiniones'] : 0 ?>';
	<?php
		function parse_signed_request($signed_request) {
		  list($encoded_sig, $payload) = explode('.', $signed_request, 2); 
		
		  $data = json_decode(base64_url_decode($payload), true);
		
		  return $data["page"]["id"];
		}
		
		function base64_url_decode($input) {
		  return base64_decode(strtr($input, '-_', '+/'));
		}
		
	?>
	var page_id = '<?php echo parse_signed_request($_POST['signed_request']);  ?>';
	$(function () {
		
        $.getJSON('metrics/fresh_scoring.php?id_resto=1&page_id=' + page_id + '&type=GET_ID_RESTO_BY_PAGE_ID', function(JSONresult) {
					
					
					// Solo para el caso que la prueba se haga desde iRestauranting
					if(page_id=='381455768647705')
						id_resto = '1303'; //NUEVE REINAS
					else
						id_resto = JSONresult[0].id_resto;	
					
					$.getJSON('metrics/fresh_scoring.php?id_resto=' + id_resto + '&intervalo=' + intervalo_fechas.toUpperCase() + '&type=IRESTAURANTING_GENERAL', 
						function(JSONresult) {
							$('#titulo_resto').text(JSONresult.description);
							$('#adress_resto').text(JSONresult.address.replace(", España",""));
							//$('#adress_resto').text(page_id);
							
							click_tab('tab_opiniones',id_resto,1);
						}
					);
					
		});
	});
	
	
	
    </script>
   
    
  <script>
  	
  </script>
    <?php include_once("analyticstracking.php") ?>
</body>

</html>